package wjl.project.dubboelabauthconsumer.SecurityConfig;

import org.springframework.security.web.authentication.WebAuthenticationDetails;
import wjl.project.dubboelabauthapi.Consts;
import wjl.project.dubboelabauthconsumer.LoginController;

import javax.servlet.http.HttpServletRequest;

public class CustomWebAuthenticationDetails extends WebAuthenticationDetails {

    private  final String loginMethod;
    /**
     * Records the remote address and will also set the session Id if a session already
     * exists (it won't create one).
     *
     * @param request that the authentication request was received from
     */
    public CustomWebAuthenticationDetails(HttpServletRequest request) {
        super(request);
        if ( null!=request.getHeader(Consts.LOGIN_HEADER_NAME)){
            loginMethod = Consts.LOGIN_METHOD_PHONE;
        }else {
            loginMethod = Consts.LOGIN_METHOD_NORMAL;
        }
    }

    public String getLoginMethod() {
        return loginMethod;
    }
}
